import dselector

from django.views.generic.simple import direct_to_template
from django.views.generic.create_update import delete_object
from django.views.decorators.csrf import csrf_protect
from django.conf.urls.defaults import *
from django.contrib import admin
from hello.views import hello_view, setup_admin
from pirate_core import redirectable, home_page
from ajaxapi.views import vote, generate_vote_content, delete_source, add_tag, starvote, spectrumvote, flagvote
from pirate_login.views import logout_view

from pirate_sources.models import URLSource

admin.autodiscover()

parser = dselector.Parser()
parser.register("file", r'[\w0-9\_]+\.?[\w0-9\_]*')

urlpatterns = patterns('',
    (r'^$', home_page),
    (r'^admin/', include(admin.site.urls)),
    (r'^setup_admin/', setup_admin),
    (r'^helloworld/', hello_view),
    (r'^sourcedelete/(?P<object_id>\d+)/$', delete_source), 
    (r'^vote/', vote),
    (r'^starvote/', starvote),
    (r'^flagvote/', flagvote),
    (r'^spectrumvote/', spectrumvote),
    (r'^add_tag/', add_tag),
    (r'^generate_vote_content/', generate_vote_content),
    (r'^comments/', include('django.contrib.comments.urls')),
    (r'^markitup/', include('markitup.urls')),
    (r'^logout/', logout_view),

)
urlpatterns += parser.patterns('',
    (r'{template:file}', csrf_protect(redirectable(direct_to_template)), {}, "pp-page"),
)
